<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:69:"C:\wamp64\www\tp\public/../application/index\view\index\register.html";i:1527598951;}*/ ?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="/static/bootstrap.css">
<script src="/static/jquery.js"></script>
<script src='/static/bootstrap.js'></script>
<style type="text/css">
.first{
	border: 2px solid #CAE1FF;
	box-shadow: 10px 10px 5px #C1CDC1;
	border-radius: 15px;
	background: #CDCDB4;
  margin-top: 15px;
}
</style>
</head>
<body>
  <div class='container'>
  
  	<div class='first col-md-4 col-md-offset-4'>
  		<h1 class='text-center'>注册用户</h1>

      <form action="<?php echo url('index/register'); ?>" method="post" enctype="multipart/form-data">
         <div class='form-group has-feedback'>
            <label class='bg-success'><big>用户名</big></label>
            <input type='text' class='form-control' name='uname' placeholder="用户名最短为3位" required>
            <p class='help-block' style='color:red;display: none'>用户名已经存在</p>
         </div>
         <div class='form-group has-feedback'>
            <label class='bg-success'><big>email</big></label>
            <input type='email' class='form-control' name='email' placeholder="一个邮箱只能在本网站使用一次">
            <p class='help-block' style='color:red;display: none;'>该email已经被使用</p>
         </div>
         <div class='form-group has-feedback'>
            <label class='bg-success'><big>tel</big></label>
            <input type='tel' name='tel'class='form-control' placeholder="请输入合法号码">
            <p class='help-block' style='color:red;display: none;'>你的电话格式有误</p>
         </div>
          <div class='form-group has-feedback'>
            <label class='bg-success'><big>个人头像</big></label>
            <input type='file' class='form-control' name='image'>
            <p class='help-block' style='color:red;display: none;'>你的头像图片没传</p>
         </div>
           <div class='form-group has-feedback'>
            <label class='bg-success'><big>密码</big></label>
            <input type='password' name='pwd' class='form-control' placeholder="密码不可以少于6位">
            <p class='help-block' style='color:red;display: none;'>你的密码太短</p>
         </div>
           <div class='form-group has-feedback'>
            <label class='bg-success'><big>重复密码</big></label>
            <input type='password' name='repwd' class='form-control'>
            <p class='help-block' style='color:red;display: none;'>你的两次密码不一致</p>
         </div> 
         <div class='form-group' >
            <button class='btn btn-primary btn-block' style='font-size: 25px;'>submit</button>
         </div> 
         <div class="text-center text-danger" style="margin-bottom: 20px;">已有账号，去
           <a href="<?php echo url('index/login'); ?>">登陆</a>
         </div>     
  	 </form>
  	</div>
  </div>
</body>
<script > 
 $("span").css({"color":"red"});
 $("span").hide();
 dui="<span class='glyphicon glyphicon-ok form-control-feedback text-info' style='color:red;'> </span>";
 cuo="<span class='glyphicon glyphicon-remove form-control-feedback text-info' style='color:red;' > </span>";
$('input[name=uname]').blur(function(){
  val=this.value;
  obj=$(this);
  $.post("<?php echo url('index/checkUser'); ?>",{val:val},function(e){
    if(e==0){
        if(val.length<3){
          obj.next().html('用户名太短');
          obj.next().show();
          obj.data({'num':0});
        }else{
          obj.next().hide();
          obj.data({'num':1});
        }
    }else{
        obj.next().html('用户名已经存在');
        obj.next().show();
        obj.data({'num':0});
    }
   })
  });
//检查该邮箱是否已经被使用
 $('input[name=email]').blur(function(){
  val=this.value;
  obj=$(this);
  $.post("<?php echo url('index/checkEmail'); ?>",{val:val},function(e){
    if(e==0){
        obj.next().hide();
        obj.data({'num':1});
    }else{
        obj.next().show();
        obj.data({'num':0});
    }
   })
 });

  $('input[name=tel]').blur(function(){
  val=this.value;
  if(!val.match(/^[1][3 5 7 9 8]\d{9}/)){
       // $(this).after(cuo);
       obj.next().show();
       $(this).data({'num':0});
  }else{
      // $(this).next().replaceWith(dui);
      obj.next().hide();
      $(this).data({'num':1});
  }
 });

$('input[name=image]').blur(function(){
  val=this.value;
  if(val!=''){
      // $(this).next().replaceWith(dui);
      $(this).next().hide();
      $(this).data({'num':1});
  }
  else{
      // $(this).after(cuo);
      $(this).next().show();
      $(this).data({'num':0});
  }
 });

 $('input[name=pwd]').blur(function(){
  val=this.value;
  if(val.length<6){
       // $(this).after(cuo);
       $(this).next().show();
       $(this).data({'num':0});
  }else{
     // $(this).next().replaceWith(dui);
     $(this).next().hide();
     $(this).data({'num':1});
  }
 });
 
 $('input[name=repwd]').blur(function(){
  val1=this.value;
  val2=$('input[name=pwd]').val();
  if(val1!=val2){
       // $(this).after(cuo);
       $(this).next().show();
       $(this).data({'num':0});
  }else{
     // $(this).next().replaceWith(dui);
     $(this).next().hide();
     $(this).data({'num':1});
  }
 });

 $('button').click(function(){
    $('input').blur();
    tol=0;
    $('input').each(function(){
        tol+=$(this).data('num');
    });
    if(tol!=6){
      return false;
    }
 })
 </script>
</html>